package registnet.cpm;

/**
 * An implementation of a node in a network diagram. A node will represent an activity in a <code>Project</code>.
 */
public class Node {
	
	/**
	 * The name of the node.
	 */
	private String name;
	
	/**
	 * The activity time duration.
	 */
	private int value;
	
	/**
	 * The earliest start of the node. Earliest start is the earliest time 
	 * at which an activity can start given that its precedent activities 
	 * must be completed first.
	 */
	private int earlyStart;
	
	/**
	 * The latest start of the node. The latest start is the latest time that
	 * an activity can start without delaying the completion of the whole project. 
	 * It is simply the latest finish minus the duration of the activity.
	 */
	private int lateStart;
	
	/**
	 * The earliest finish of the node. The earliest finish is the time that 
	 * an activity will be finished given that it starts at its earliest
	 * start time. It is simply the earliest start plus the duration of
	 * the activity
	 */
	private int earlyFinish;
	
	/**
	 * The latest finish of the node. Latest finish is the latest time that 
	 * an activity can be completed without delaying the completion of the whole project.
	 */
	private int lateFinish;
	
	/**
	 * The slack time of the node. Slack time is the leeway time of the activity;
	 * it is the maximum time that the activity can be delayed without delaying the
	 * whole project.
	 */
	private int slack;
	
	/**
	 * A flag for determining if the node is visited or not.
	 */
	private boolean visited;
	
	/**
	 * Creates a node with the given name.
	 * @param name
	 */
	public Node(String name){
		this.name = name;
		this.visited = false;
	}
	
	/**
	 * Creates a node with the given name and value.
	 * @param name
	 * @param value
	 */
	public Node(String name, int value){
		this.name = name;
		this.value = value;
		this.visited = false;
	}
	
	/**
	 * Sets the name of the node.
	 * @param name
	 */
	public void setName(String name){
		this.name = name;
	}
	
	/**
	 * Returns the name of the node.
	 * @return the name of the node
	 */
	public String getName(){
		return this.name;
	}
	
	/**
	 * Sets the value of the node.
	 * @param value
	 */
	public void setValue(int value){
		this.value = value;
	}
	
	/**
	 * Returns the value of the node.
	 * @return the value of the node
	 */
	public int getValue(){
		return this.value;
	}
	
	/**
	 * Sets the early start of the node.
	 * @param earlyStart
	 */
	public void setEarlyStart(int earlyStart){
		this.earlyStart = earlyStart;
	}
	
	/**
	 * Returns the early start of the node.
	 * @return the early start of the node
	 */
	public int getEarlyStart(){
		return this.earlyStart;
	}
	
	/**
	 * Sets the early finish of the node.
	 * @param earlyFinish
	 */
	public void setEarlyFinish(int earlyFinish){
		this.earlyFinish = earlyFinish;
	}
	
	/**
	 * Returns the early finish of the node.
	 * @return the early finish of the node
	 */
	public int getEarlyFinish(){
		return this.earlyFinish;
	}
	
	/**
	 * Sets the late start of the node.
	 * @param lateStart
	 */
	public void setLateStart(int lateStart){
		this.lateStart = lateStart;
	}
	
	/**
	 * Returns the late start of the node.
	 * @return the late start of the node
	 */
	public int getLateStart(){
		return this.lateStart;
	}
	
	/**
	 * Sets the late finish of the node.
	 * @param lateFinish
	 */
	public void setLateFinish(int lateFinish){
		this.lateFinish = lateFinish;
	}
	
	/**
	 * Returns the late finish of the node.
	 * @return the late finish of the node
	 */
	public int getLateFinish(){
		return this.lateFinish;
	}
	
	/**
	 * Sets the slack of the node.
	 * @param slack
	 */
	public void setSlack(int slack){
		this.slack = slack;
	}
	
	/**
	 * Returns the slack of the node.
	 * @return the slack of the node
	 */
	public int getSlack(){
		return this.slack;
	}

	/**
	 * Returns the value of the flag <code>isVisited</code>.
	 * @return the value of the flag <code>isVisited</code>
	 */
	public boolean isVisited() {
		return visited;
	}

	/**
	 * Sets  the value of the flag <code>isVisited</code>
	 * @param visited
	 */
	public void setVisited(boolean visited) {
		this.visited = visited;
	}
	
}
